// 路由表文件
// 需要使用按需加载(路由懒加载)
import { lazy, Suspense } from "react";
import { Navigate } from "react-router-dom";

const Login = lazy(() => import("../pages/login/Index"));
const Home = lazy(() => import("../pages/home/Index"));

const Main = lazy(() => import("../pages/home/main/Index"));
const BannerList = lazy(() => import("../pages/home/bannerlist/Index"));
const BannerAdd = lazy(() => import("../pages/home/banneradd/Index"));
const Project = lazy(() => import("../pages/home/project/Index"));

const UserList = lazy(() => import("../pages/home/userlist/Index"));
const UserAdmin = lazy(() => import("../pages/home/useradmin/Index"));
const Echarts = lazy(() => import("../pages/home/echarts/Index"));
const Editor = lazy(() => import("../pages/home/editor/Index"));
const Md = lazy(() => import("../pages/home/md/Index"));
const Export = lazy(() => import("../pages/home/export/Index"));
const Import = lazy(() => import("../pages/home/import/Index"));
const Map = lazy(() => import("../pages/home/map/Index"));

const routes = [
  {
    path: "/",
    element: <Navigate to="/login"></Navigate>,
  },
  {
    path: "/login",
    element: (
      <Suspense>
        <Login />
      </Suspense>
    ),
  },
  {
    path: "/home",
    element: (
      <Suspense>
        <Home />
      </Suspense>
    ),
    children: [
      {
        path: "/home/main",
        element: (
          <Suspense>
            <Main />
          </Suspense>
        ),
      },
      {
        path: "/home/bannerlist",
        element: (
          <Suspense>
            <BannerList />
          </Suspense>
        ),
      },
      {
        path: "/home/banneradd",
        element: (
          <Suspense>
            <BannerAdd />
          </Suspense>
        ),
      },
      {
        path: "/home/project",
        element: (
          <Suspense>
            <Project />
          </Suspense>
        ),
      },

      {
        path: "/home/userlist",
        element: (
          <Suspense>
            <UserList />
          </Suspense>
        ),
      },
      {
        path: "/home/useradmin",
        element: (
          <Suspense>
            <UserAdmin />
          </Suspense>
        ),
      },
      {
        path: "/home/echarts",
        element: (
          <Suspense>
            <Echarts />
          </Suspense>
        ),
      },
      {
        path: "/home/editor",
        element: (
          <Suspense>
            <Editor />
          </Suspense>
        ),
      },
      {
        path: "/home/md",
        element: (
          <Suspense>
            <Md />
          </Suspense>
        ),
      },
      {
        path: "/home/export",
        element: (
          <Suspense>
            <Export />
          </Suspense>
        ),
      },
      {
        path: "/home/import",
        element: (
          <Suspense>
            <Import />
          </Suspense>
        ),
      },
      {
        path: "/home/map",
        element: (
          <Suspense>
            <Map />
          </Suspense>
        ),
      },
    ],
  },
];

export default routes;
